web3.js web3.utils.toTwosComplement
web3.utils.toTwosComplement(number)
負の数を2の補数に変換します。
パラメータ
1. number - Number|String|BigNumber
戻り値
String
サンプル
code:ex.js
web3.utils.toTwosComplement('-1');
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
web3.utils.toTwosComplement(-1);
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
web3.utils.toTwosComplement('0x1');
"0x0000000000000000000000000000000000000000000000000000000000000001"
web3.utils.toTwosComplement(-15);
"0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1"
web3.utils.toTwosComplement('-0x1');
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
参考